home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr40 / aprs67.zip / FILTRHST.BAS < prev    next >
BASIC Source File  |  1994-01-13  |  4KB  |  89 lines

  1. REM THIS PROGRAM CURRENTLY CONFIGURED TO BUILD A FILTERED TRACK HISTORY FILE
  2. REM FROM A NUMBER OF SOURCE HISTORY FILES.  THE FILTERING IS NOT AS IMPORTANT
  3. REM AS IT USED TO BE, BECAUSE NOW APRS PRE-FILTERS ALL POSITION REPORTS BEFORE
  4. REM EVEN SAVING THEM TO A TRACK HISTORY FILE.
  5. REM
  6. REM It will filter out all position reports that are within a specified range
  7. REM of each other.  It is primarily used to eliminate all duplicate points
  8. REM while a station is stationary.  By making the range about .3 miles, almost
  9. REM all points from a boat in port including the errors of GPS selective
  10. REM availability will be eliminated.
  11. REM
  12. REM
  13. DIM P$(59), Num(39)
  14. LineP = 1: P$(1) = "NOTHING HERE TO START"
  15. REM ON ERROR GOTO ErrorTrap
  16.  
  17.     CLS
  18.     INPUT "Enter file name for accumulation of output if other than FILTROUT.HST"; F$
  19.     IF F$ = "" THEN F$ = "FILTROUT.HST"
  20.     OPEN F$ FOR OUTPUT AS #5
  21.     PRINT
  22.     INPUT "Enter range delta in miles if other than 0.3"; Del$
  23.     IF Del$ = "" THEN Del$ = ".3"
  24.  
  25. REM BEGIN HERE TO REPETITIVELY ASK FOR THE NEXT SOURCE FILE
  26. DO UNTIL UCASE$(a$) = "END"
  27. ReDo: CLS : LOCATE 1, 47: PRINT "NumLines", "NumGood"
  28.       LOCATE 3, 47: PRINT i, j
  29.       LOCATE 4, 1: PRINT "Units found in file"
  30.       LOCATE 6, 1: FOR ip = 1 TO LineP: PRINT LEFT$(P$(ip), 25), Num(ip): NEXT ip
  31.       LOCATE 1, 1
  32.       INPUT "Enter xxxxx.HST file name for filtering (or end)"; F$
  33.       IF UCASE$(F$) = "END" THEN EXIT DO
  34.       OPEN "b:" + F$ + ".hst" FOR INPUT AS #3
  35.       IF Fault = 53 THEN GOTO ReDo
  36.  
  37.    REM BEGIN HERE TO READ EVERY ENTRY IN THE xxxxx.HST FILE AND FILTER IT
  38.    DO WHILE NOT EOF(3)
  39.       LINE INPUT #3, a$
  40.       IF a$ <> "" THEN
  41.          PM = 0: i = i + 1
  42.          REM BUILD AN ARRAY OF ALL DIFFERENT STATIONS, SO THAT WE KEEP THE LATEST
  43.          REM POSIT OF EACH STATION FOR COMPARISON WITH EACH NEW POSIT IN THE FILE
  44.    
  45.          FOR ip = 1 TO LineP ' Identify which boat and add to array if new boat
  46.              IF LEFT$(a$, 9) = LEFT$(P$(ip), 9) THEN
  47.                 PM = ip: ip = LineP: Num(PM) = Num(PM) + 1
  48.                 END IF
  49.          NEXT ip: IF PM = 0 THEN LineP = LineP + 1: PM = LineP: Num(PM) = 1
  50.          REM Now compare new value with old value
  51.          IF ABS(VAL(MID$(a$, 26, 7)) - VAL(MID$(P$(PM), 26, 7))) > VAL(Del$) THEN
  52.             PRINT #5, a$: j = j + 1: P$(PM) = a$: LOCATE 3, 47: PRINT i, j
  53.          ELSEIF ABS(VAL(MID$(a$, 35, 8)) - VAL(MID$(P$(PM), 35, 8))) > VAL(Del$) THEN
  54.             PRINT #5, a$: j = j + 1: P$(PM) = a$: LOCATE 3, 47: PRINT i, j
  55.          END IF
  56.          REM the following line if activated assures that each new point is
  57.          REM always compared with the previous point no matter what it is...
  58.          REM In otherwords, the program works like a filter to remove adjacent
  59.          REM points that are closer than delta apart.
  60.          REM HOWEVER, if the following line is iimplemented in the above two
  61.          REM lines after each save, then the program operates like a step
  62.          REM filter throwing out all points EXCEPT for points separated by DEL
  63.          REM This results in an evenly spaced track history every DEL miles
  64.          REM P$(PM) = a$: LOCATE 3, 47: PRINT i, j
  65.       END IF
  66.    LOOP ' Loop back to read the next POSIT in this file
  67.    CLOSE 3
  68.  
  69. LOOP ' Loop back to beginning and ask for the next xxxx.HST file
  70. CLOSE 5: PRINT : PRINT "Filtered data from all files stored in FILTROUT.HST"
  71. INPUT "Hit return to conitinue..."; a$
  72. SYSTEM
  73.  
  74. ErrorTrap: Fault = ERR: LOCATE 2, 60'Error handling routine
  75.      ercntr = ercntr + 1: REM IF ercntr > 6 THEN INPUT "in err routine"; a$
  76.      IF ERR = 57 THEN PRINT "  I/O-error-User-"; : RESUME
  77.      IF ERR = 69 THEN PRINT "  Comm-buffer-overflow"; : RESUME
  78.      IF ERR = 53 THEN PRINT file$; "-NotFound": CLOSE #3: CLOSE #5: RESUME NEXT
  79.      IF ERR = 52 THEN PRINT file$; "-Bad#": CLOSE #3: CLOSE #5: RESUME NEXT
  80.      IF ERR = 64 THEN PRINT file$; "-BadName": CLOSE #3: CLOSE #5: RESUME NEXT
  81.      IF ERR = 62 THEN RESUME NEXT  'Read past end of file
  82.      IF ERR = 2 THEN PRINT "SYNTAX-error"
  83.      RESET: PRINT : PRINT "Error I cant fix. Number = "; ERR;
  84.      INPUT "Program crashed.  Sorry.  Hit RETURN to return to DOS"; a$
  85.      SYSTEM
  86.  
  87. END
  88.  
  89.